package com.gzz.orchid.context.application.merch.convert;

import com.gzz.orchid.context.application.merch.command.BrandSaveCmd;
import com.gzz.orchid.context.application.merch.pojo.BrandDto;
import com.gzz.orchid.context.application.merch.pojo.BrandVo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.base.BaseBrandPo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

/**
 * @author higmd
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, imports = {Status.class})
public interface BrandConverter {
    BrandConverter INSTANCE = Mappers.getMapper(BrandConverter.class);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    BrandVo mapVo(BaseBrandPo po);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    BrandDto mapDto(BaseBrandPo po);

    void updatePo(@MappingTarget BaseBrandPo po, BrandSaveCmd cmd);
}
